<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>意达设计</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../css/member.css"/>

</head>
<body class="body">

<!-- header -->
<div class="searchHeader">
	<a href="javascript:void(0);" onclick="api.closeWin();"></a>
	<input type="text" id="key" placeholder="请输入搜索内容">
	<a href="javascript:void(0)" class="searchlink">搜索</a>
</div>

<!-- contact -->
<div class="wrop">
	<div class="searchTit"><span>热门搜索</span></div>
	<div class="serlie">
		<ul id='hotbrand'>
			
		</ul>
	</div>
	<div class="anbatch"><a href="#" onclick="hotbrand()">换一批</a></div>
</div>

<div class="hr hrBG1"></div>

<div class="wrop">
	<div class="searchTit"><span>热门搜索</span><a href="javascript:void(0);"  onclick="clearhistory()">清除</a></div>
	<div class="cealie">
		<ul id='history'>
			<li><a href="javascript:void">保尔伯德</a></li>
			<li><a href="javascript:void">NIKE</a></li>
			<li><a href="javascript:void">POLO</a></li>
			<li><a href="javascript:void">手提包</a></li>
			<li><a href="javascript:void">单肩包</a></li>
		</ul>
	</div>
</div>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="../script/adaptive.js"></script>
<script type="text/javascript" src="../script/tabs.js"></script>
<script type="text/javascript">
    window['adaptive'].desinWidth = 750;
    window['adaptive'].baseFont = 28;
    window['adaptive'].maxWidth = 750;
    window['adaptive'].init();

    apiready = function () {
        $api.fixStatusBar($api.dom('.header'));
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err){
            api.closeWidget();
        });
        api. addEventListener({name:'scrolltobottom'}, function(ret, err){
            //refresh event callback
            //toDoRequest();

        });
        api.showProgress();

        var para=api.pageParam;

        var p= {type:1,token:token};
        api.ajax({
            url: webSiteUrl+'/app/user/history',
            method: 'post',
            data: {
                
                values: p
            }
        }, function(ret, err) {
            api.hideProgress();
            
            if(ret.code==200){
                
                var tj=ret.data;
				html = "";
                for(var i=0;i<tj.length;i++){
html+= '<li onclick="searchPlay('+tj[i].key+')"><a href="javascript:void(0);">'+tj[i].key+'</a></li>';
                }
                $('#history').html(html);


                

            }else{
                //alert(ret.msg);
                $('#history').html('<p style="text-align:center">暂无数据</p>');

                
            }
            hotbrand();
        });

    };
		
    $('.searchlink').click(function(){
        var key=$('#key').val();
        if(key==""){
            alert('请输入搜索内容');return;
        }
        var p={type:3,token:token,key:key};
        api.ajax({
            url: webSiteUrl+'/app/user/history',
            method: 'post',
            data: {
                
                values: p
            }
        }, function(ret, err) {
            
            
            if(ret.code==200){
                searchPlay(key);
               

            }else{
                alert(ret.msg)
            }
        });
        
    });

    function hotbrand(){
    	api.ajax({
            url: webSiteUrl+'/app/public/hotbrand',
            method: 'post',
            data: {
                
                values: {}
            }
        }, function(ret, err) {
            api.hideProgress();
            
            if(ret.code==200){
                
               var tj=ret.data;
				html = "";
                for(var i=0;i<tj.length;i++){
html+= '<li onclick="searchBrand('+tj[i].id+')" data="'+tj[i].name+'" id="'+tj[i].id+'"><a href="javascript:void(0);">'+tj[i].name+'</a></li>';
                }
                $('#hotbrand').html(html);

            }else{alert(ret.msg)}
        });
    }

    
    function clearhistory(){
        var p={type:2,token:token};
    	api.ajax({
            url: webSiteUrl+'/app/user/history',
            method: 'post',
            data: {
                
                values: p
            }
        }, function(ret, err) {
            api.hideProgress();
            $('#history').empty();
            if(ret.code==200){
                
               

            }else{
                //alert(ret.msg)
            }
        });
    }
    function searchBrand(id){
        var key=$('#'+id).attr('data');
        searchPlay(key);
    }
</script>

</html>
